﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using DatabaseAccessLayer;
using System.Configuration;

namespace WebApplication
{
    public partial class Membership_Complete : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ((System.Web.UI.HtmlControls.HtmlGenericControl)Master.FindControl("divbreadcrum")).InnerHtml = @"<a href='default.aspx'>Home</a> > <a href='Sign-In.aspx'>Sign In</a> > <a href='Membership.aspx'>New Registration</a> > <span>Membership - Finish</span>";
        }
        public void btnSubmit_Click(object sender, EventArgs e)
        {
            if (chkValidate.Checked)
            {
                string Timing = "";
                foreach (ListItem item in chkResidentialMgmt.Items)
                {
                    if (item.Selected)
                    {
                        Timing = chkResidentialMgmt.SelectedItem.Text + ",";
                    }
                }

                int UserID = Convert.ToInt32(Request.QueryString["ID"]);
                if (upFile.HasFile)
                {
                    upFile.PostedFile.SaveAs(Server.MapPath("UploadedFiles/UserPhoto/") + UserID + Path.GetExtension(upFile.PostedFile.FileName));
                }
                int Result = clsUser.MemberShipUserComplete(UserID, Timing, UserID + Path.GetExtension(upFile.PostedFile.FileName), chkSpecialOffer.Checked);
                {
                    string MailContent = File.ReadAllText(Server.MapPath("signup-email.html"));
                    MailContent = MailContent.Replace("####", "http://realestate-contracting.com" + "/MembershipActivation.aspx?ID=" + UserID);
                    Utility.sendMail(Convert.ToString(Session["EmilID"]), "Please activate your account", MailContent);
                    Utility.sendMail(ConfigurationManager.AppSettings["AdminEmail"].ToString(), "Member User Registration", "A new " + Session["FirstName"] + " " + Session["LastName"] + " has current registered in RealStudio");
                    Response.Redirect("ThankYou.aspx");
                }
                
            }
            else
            {
                lblMessage.Text = "Please select acknowledgement to proceed.";
            }



        }
    }
}